package com.atguigu.gulimail.search.conf;

import org.apache.http.HttpHost;
import org.elasticsearch.client.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author Fengkai
 * @creat 2022/1/1
 */
@Configuration
public class GulimailElsConfig {


    public static final RequestOptions COMMON_OPTIONS;
    static {

        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
//        builder.addHeader("Authorization", "Bearer " + TOKEN);
//        builder.setHttpAsyncResponseConsumerFactory(
//                new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory(30*1024*1024*1024)
//
//        );
        COMMON_OPTIONS = builder.build();
    }

        @Bean
        public RestHighLevelClient esRest(){
            RestHighLevelClient restHighLevelClient = new RestHighLevelClient(
                    RestClient.builder(
                            new HttpHost("192.168.157.128", 9200, "http")
                    )

            );
            return  restHighLevelClient;
        }

}
